package org.budo.phone.location.service.api.util;

import org.budo.phone.location.service.api.BudoPhoneLocation;
import org.budo.support.lang.util.StringUtil;

import lombok.extern.slf4j.Slf4j;

/**
 * @author lmw
 */
@Slf4j
public class PhoneLocationUtil {
    public static boolean sameCity(BudoPhoneLocation sourceLocation, BudoPhoneLocation destinationLocation) {
        if (null == sourceLocation || null == destinationLocation) {
            log.error("#15 sourceLocation=" + sourceLocation + ", destinationLocation=" + destinationLocation + ", return false");
            return false;
        }

        String sourceProvince = sourceLocation.getProvince();
        String destinationProvince = destinationLocation.getProvince();
        String sourceCity = sourceLocation.getCity();
        String destinationCity = destinationLocation.getCity();

        if (null == sourceProvince || null == destinationProvince //
                || null == sourceCity || null == destinationCity) {
            log.error("#26 sourceLocation=" + sourceLocation + ", destinationLocation=" + destinationLocation + ", return false");
            return false;
        }

        return StringUtil.equals(sourceProvince, destinationProvince) && StringUtil.equals(sourceCity, destinationCity);
    }
}